package com.zb;

import com.zb.entity.TbSkuModel;
import com.zb.service.SearchService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

@SpringBootApplication
public class MySearchApplication {
    public static void main(String[] args) throws Exception {
        ConfigurableApplicationContext run = SpringApplication.run(MySearchApplication.class, args);
        SearchService searchService = run.getBean(SearchService.class);
//        searchService.createIndex();
//        searchService.importData();
        Map<String, String> map = new HashMap<>();
        map.put("index", "1");
        map.put("size", "20");
        map.put("keyword", "小米");
//        map.put("brand","瑞动");
        map.put("category", "拉杆箱");
//        map.put("spec_尺寸", "17英寸");
        map.put("sortFeild","price");
        map.put("sortRule","asc");
//        map.put("price","50000-60000");
//        map.put("price","60000-*");
//        map.put("spec_颜色","蓝色");
        Map<String, Object> search = searchService.search(map);

        List<String> brandList = (List<String>) search.get("brandList");
        for (String s : brandList) {
            System.out.println(s);
        }
        System.out.println("========================");
        List<String> cateList = (List<String>) search.get("cateList");
        for (String s : cateList) {
            System.out.println(s);
        }
        System.out.println("========================");
        Map<String, Set> specMap = (Map<String, Set>) search.get("specMap");
        System.out.println(specMap);
        System.out.println("========================");
        List<TbSkuModel> list = (List<TbSkuModel>) search.get("skuModels");
        for (TbSkuModel skuModel : list) {
            System.out.println(skuModel);
        }
    }
}
